package com.cn.wanxi.service.impl;

import com.cn.wanxi.model.ProductModel;
import com.cn.wanxi.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class ProductImpl implements ProductDao {
    @Override
    public List<ProductModel> getHomeList() {
        String sql = "select * from product limit 2";
        ResultSet resultSet = JDBC.getResultSet(sql);
        List<ProductModel> list = new ArrayList<>();
        try {
            while (resultSet.next()) {
                ProductModel model = new ProductModel();
                model.setImgHref(resultSet.getString("imgHref"));
                model.setContent(resultSet.getString("content"));
                model.setTitle(resultSet.getString("title"));
                list.add(model);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }
}
